<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>简博客-留言板</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/nprogress.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="apple-touch-icon-precomposed" href="images/icon/icon.jpg">
<link rel="shortcut icon" href="images/icon/icon.jpg">
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/jquery.lazyload.min.js"></script>
<!--[if gte IE 9]>
  <script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>
  <script src="js/html5shiv.min.js" type="text/javascript"></script>
  <script src="js/respond.min.js" type="text/javascript"></script>
  <script src="js/selectivizr-min.js" type="text/javascript"></script>
<![endif]-->
<!--[if lt IE 9]>
  <script>window.location.href='upgrade-browser.html';</script>
<![endif]-->
</head>

<body class="user-select">
<header class="header">
  <nav class="navbar navbar-default" id="navbar">
    <div class="container">
      <div class="header-topbar hidden-xs link-border">
        <ul class="site-nav topmenu">
          <li><a href="links.html" rel="nofollow">友情链接</a></li>
          <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" rel="nofollow">关于作者<span class="caret"></span></a>
            <ul class="dropdown-menu header-topbar-dropdown-menu">
              <li><a data-toggle="modal" data-target="#WeChat" rel="nofollow"><i class="fa fa-weixin"></i> 微信</a></li>
              <li><a href="https://www.jianshu.com/u/31ccce39a24b" target="_blank" rel="nofollow"><i class="fa fa-weibo"></i> 简书</a></li>
              <li><a href="https://www.cnblogs.com/smfx1314/" target="_blank" rel="nofollow"><i class="fa fa-rss"></i> 博客园</a></li>
              <li><a href="https://github.com/smfx1314" target="_blank" rel="nofollow"><i class="fa fa-rss"></i> GitHub</a></li>
            </ul>
          </li>
        </ul>
        <a data-toggle="modal" data-target="#loginModal" class="login" rel="nofollow">Hi,你好</a>&nbsp;&nbsp; </div>
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#header-navbar" aria-expanded="false"> <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
        <h1 class="logo hvr-bounce-in"><a href="" title=""><img src="images/logo.png" alt=""></a></h1>
      </div>
      <div class="collapse navbar-collapse" id="header-navbar">
        <ul class="nav navbar-nav navbar-right">
          <li><a data-cont="首页" href="index.html">首页</a></li>
          <li><a href="tags.html">标签</a></li>
          <li class="active"><a href="readerinfo.html">留言</a></li>
        </ul>
      </div>
    </div>
  </nav>
</header>
<section class="container container-page">
  <div class="content">
    <header class="article-header">
      <h1 class="article-title">留言板</h1>
    </header>
    <div class="form-group">
      <label for="exampleInputEmail1">昵称</label>
      <input type="text" class="form-control" id="name" placeholder="怎么称呼">
    </div>
    <div class="form-group">
      <label for="exampleInputEmail1">主题</label>
      <input type="text" class="form-control" id="title" placeholder="主题">
    </div>
    <div class="form-group">
      <label for="exampleInputEmail1">内容</label>
      <textarea class="form-control" id="content" placeholder="开始留言"></textarea>
    </div>
    <div class="form-group">
      <label for="exampleInputEmail1">Email</label>
      <input type="email" class="form-control" id="email" placeholder="你的邮箱">
    </div>
    <button type="button" id="submit" class="btn btn-success">提交</button>
  </div>
</section>
<footer class="footer">
  <div class="container">
    <p>&copy; 2016 <a href="">ylsat.com</a> &nbsp; <a href="#" target="_blank" rel="nofollow">豫ICP备20151109-1</a> &nbsp; &nbsp; <a href="http://www.mycodes.net/" target="_blank">源码之家</a></p>
  </div>
  <div id="gotop"><a href="#" class="gotop"></a></div>
</footer>
<!--微信二维码模态框-->
<div class="modal fade user-select" id="WeChat" tabindex="-1" role="dialog" aria-labelledby="WeChatModalLabel">
  <div class="modal-dialog" role="document" style="margin-top:120px;max-width:280px;">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="WeChatModalLabel" style="cursor:default;">微信扫一扫(备注)</h4>
      </div>
      <div class="modal-body" style="text-align:center"> <img src="images/weixin.jpg" alt="" style="cursor:pointer"/> </div>
    </div>
  </div>
</div>
<script src="js/bootstrap.min.js"></script> 
<script src="js/jquery.ias.js"></script> 
<script src="js/scripts.js"></script>


<script type="text/javascript">
  $(function(){
    $("#submit").on("click",function(){

      var name = $("#name").val();
      var title = $("#title").val();
      var content = $("#content").val();
      var email = $("#email").val();
      if (name=="") {
        alert("怎么称呼？")
        return false;
      }
      if (title=="") {
        alert("主题记得填一下")
        return false;
      }
      if (content=="") {
        alert("怎么不写点内容呢？")
        return false;
      }
      if (email=="") {
        alert("留个邮箱联系")
        return false;
      }

      $.ajax({
            url:"http://localhost:8081/front/insertMsg",
            type:"POST",
            xhrFields:{
              widthCredentials:true
            },
            data:{
              "name": name,
              "title": title,
              "content": content,
              "email": email
            },
            success:function (result) {
                if (0 == result.code){
                  alert("留言成功")
                  window.location.href="readerinfo.html";      
                }else{
                  alert("失败，重新试试")
                }
            }

        });
              //获取表单提交按钮
     var btnSubmit = document.getElementById("submit");
     //将表单提交按钮设置为不可用，这样就可以避免用户再次点击提交按钮
     btnSubmit.disabled= "disabled";
     //返回true让表单可以正常提交
     return true;
    })
  })
</script>
</body>
</html>